﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DayPilot.Web.Ui;

/// <summary>
/// Summary description for ObjectUtils
/// </summary>
public class ObjectUtils
{

    /// <summary>
    /// wraps predefined objects with desired attributes and provides them to calling instances
    /// </summary>
    public ObjectUtils()
    {
       
    }

    /// <summary>
    /// initialises the DayPilot Calendar control used by this system
    /// </summary>
    /// <param name="EventCalendar"></param>
    public static void initCalendar(DayPilotCalendar EventCalendar)
    {

        EventCalendar.BusinessBeginsHour = 8;
        EventCalendar.BusinessEndsHour = 20;
        EventCalendar.Days = 7;
        EventCalendar.StartDate = Convert.ToDateTime("23 March 2009");
        EventCalendar.HeaderDateFormat = "dddd";
        EventCalendar.TimeFormat = TimeFormat.Clock24Hours;



    }

    /// <summary>
    /// randomises elements in List
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="list"></param>
    /// <returns></returns>
    public static List<T> Randomize<T>(List<T> list)
    {
        List<T> randomizedList = new List<T>();
        Random rnd = new Random();
        while (list.Count > 0)
        {
            int index = rnd.Next(0, list.Count); //pick a random item from the master list
            randomizedList.Add(list[index]); //place it at the end of the randomized list
            list.RemoveAt(index);
        }
        return randomizedList;
    }

}
